package com.codechuan.didi_web.controller;

import com.codechuan.didi_web.service.SysUserOrderService;
import com.codechuan.didi_web.utils.ResultUtils;
import com.codechuan.didi_web.vo.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/order")
public class OrderController {

    @Resource
    private SysUserOrderService sysUserOrderService;

    /**
     * @param account 账户/卡密
     * @return 返回查询到的数据
     * @Deprecated 查询用户自己的所有订单
     */
    @GetMapping(value = "/getMyOrderList")
    public ResultVO<Object> getMyOrderList(@RequestHeader("token") String account) {
        try {
            return sysUserOrderService.getMyOrderList(account);
        } catch (Exception e) {
            return ResultUtils.error(500, "网络异常请重新刷新页面", "");
        }
    }

    /**
     * @param orderId 订单编号
     * @Deprecated 删除用户的订单
     */
    @GetMapping(value = "/deleteOrder")
    public ResultVO<Object> deleteOrder(Integer orderId) {
        try {
            return sysUserOrderService.deleteOrder(orderId);
        } catch (Exception e) {
            return ResultUtils.error(500, "网络异常请重新刷新页面", "");
        }
    }
}
